﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.Entity.ModelConfiguration;
using Yala.Models.Users;

namespace Yala.DataAccess.Common.EF.Mappings {
    public class UserConfiguration : EntityTypeConfiguration<User> {
        public UserConfiguration() {
            ToTable("Users");
            HasKey(x => x.Id).Property(x => x.Id).HasColumnName("UserId").IsRequired();
            Property(x => x.Username).HasColumnName("Username");
            Property(x => x.Email).HasColumnName("Email");
            Property(x => x.OpenId).HasColumnName("OpenId");
            Property(x => x.LastLogOnDate).HasColumnName("LastLogOnDate");
            HasRequired(x => x.AuthProvider).WithMany(x => x.Users).Map(x => x.MapKey("AuthProviderId"));

            // ignore these properties
            Ignore(x => x.FirstName);
            Ignore(x => x.MiddleName);
            Ignore(x => x.LastName);        
        }
    }
}
